package api

import (
	"cap_client/service"
	"github.com/gin-gonic/gin"
	"lib/http"
)

var ClientApi = new(clientApi)

type clientApi struct {
}

func (a clientApi) Register(c *gin.Context) {
	err := service.ClientSer.Register()
	if err != nil {
		http.BadWithErr(c, err)
		return
	}
	http.OK204(c)
}

func (a clientApi) UploadCloudApp(c *gin.Context) {
	err := service.ClientSer.UploadCloudApp()
	if err != nil {
		http.BadWithErr(c, err)
		return
	}
	http.OK204(c)
}
func (a clientApi) CreateRdpWinAccount(c *gin.Context) {
	in := struct {
		Kvs []string `json:"kvs"`
	}{}
	if err := c.ShouldBindJSON(&in); err != nil {
		http.BadWithParamsError(c, err)
		return
	}
	err := service.ClientSer.CreateRdpWinAccount(in.Kvs)
	if err != nil {
		http.BadWithErr(c, err)
		return
	}
	http.OK204(c)
}
